<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <h:form id="subGrupoSearch" styleClass="edit">

        <rich:simpleTogglePanel label="Subgrupo: Filtro de Pesquisa" switchType="ajax">
            <s:div styleClass="tableControl" rendered="#{empty from}">
        		<s:link view="/resources/SubGrupoEdit.xhtml"
		                    id="create"
		           propagation="none">
		            <h:graphicImage url="/img/add.png"/>
		            #{' '}
		            <h:outputLabel value="Novo"/>
		            <f:param name="subGrupoId"/>
		            <f:param name="grupoId" value="#{subGrupoList.grupo.id}"/>
		        </s:link>
		    </s:div>
            
            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Nome</ui:define>
                <h:inputText id="nome" value="#{subGrupoList.subGrupo.nome}"/>
            </s:decorate>
            
            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Descrição</ui:define>
                <h:inputText id="descricao" value="#{subGrupoList.subGrupo.descricao}"/>
            </s:decorate>
            
            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">E-mail</ui:define>
                <h:inputText id="email" value="#{subGrupoList.subGrupo.email}"/>
            </s:decorate>
            
            <s:decorate id="padrao" template="/layout/display.xhtml">
				<ui:define name="label">Padrão</ui:define>
            	<h:selectOneRadio id="padrao" value="#{subGrupoList.subGrupo.padrao}" styleClass="radio" required="true">
                    <f:selectItem itemLabel="Sim" itemValue="true"/>
                    <f:selectItem itemLabel="Não" itemValue="false"/>
                </h:selectOneRadio>
			</s:decorate>
            
            <s:decorate id="status" template="/layout/display.xhtml">
				<ui:define name="label">Status</ui:define>
            	<h:selectOneRadio id="status" value="#{subGrupoList.subGrupo.status}" styleClass="radio" required="true">
                    <f:selectItem itemLabel="Ativo" itemValue="Ativo"/>
                    <f:selectItem itemLabel="Inativo" itemValue="Inativo"/>
                </h:selectOneRadio>
			</s:decorate>

            <s:decorate template="/layout/display.xhtml">
                <ui:define name="label">Combinar campos?</ui:define>
                <h:selectOneRadio id="logic" value="#{subGrupoList.restrictionLogicOperator}" styleClass="radio">
                    <f:selectItem itemLabel="Sim" itemValue="and"/>
                    <f:selectItem itemLabel="Não" itemValue="or"/>
                </h:selectOneRadio>
            </s:decorate>
			
			<s:decorate template="/layout/display.xhtml">
				<h:commandButton id="search" value="Pesquisar" action="/resources/SubGrupoList.xhtml"/>
            	<s:button id="reset" value="Limpar" includePageParams="false"/>
            	</s:decorate>
        </rich:simpleTogglePanel>

    </h:form>

	<br clear="left"/>

    <rich:panel>
        <f:facet name="header">Subgrupo: Resultados da Pesquisa (#{empty subGrupoList.resultList ? 0 : (subGrupoList.paginated ? subGrupoList.resultCount : subGrupoList.resultList.size)})</f:facet>
    <div class="results" id="subGrupoList">

    <h:outputText value="A pesquisa não retornou resultados."
               rendered="#{empty subGrupoList.resultList}"/>

    <rich:dataTable id="subGrupoList"
                var="_subGrupo"
              value="#{subGrupoList.resultList}"
           rendered="#{not empty subGrupoList.resultList}"
         rowClasses="odd,even"
         	   rows="20">
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{subGrupoList}"/>
                    <ui:param name="propertyLabel" value="Nome"/>
                    <ui:param name="propertyPath" value="subGrupo.nome"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_subGrupo.nome}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{subGrupoList}"/>
                    <ui:param name="propertyLabel" value="Descrição"/>
                    <ui:param name="propertyPath" value="subGrupo.descricao"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_subGrupo.descricao}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{subGrupoList}"/>
                    <ui:param name="propertyLabel" value="E-mail"/>
                    <ui:param name="propertyPath" value="subGrupo.email"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_subGrupo.email}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{subGrupoList}"/>
                    <ui:param name="propertyLabel" value="Data de Cadastro"/>
                    <ui:param name="propertyPath" value="subGrupo.dataCadastro.time"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_subGrupo.dataCadastro.time}"/>
        </h:column>
        <rich:column style="text-align: center;">
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{subGrupoList}"/>
                    <ui:param name="propertyLabel" value="Padrão"/>
                    <ui:param name="propertyPath" value="subGrupo.padraoString"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_subGrupo.padraoString}"/>
        </rich:column>
        
        <h:column>
            <f:facet name="header">
                <ui:include src="/layout/sort.xhtml">
                    <ui:param name="entityList" value="#{subGrupoList}"/>
                    <ui:param name="propertyLabel" value="Status"/>
                    <ui:param name="propertyPath" value="subGrupo.status"/>
                </ui:include>
            </f:facet>
            <h:outputText value="#{_subGrupo.status}"/>
        </h:column>
        <rich:column styleClass="action">
            <f:facet name="header">Opções</f:facet>
            <s:link view="/resources/#{empty from ? 'SubGrupo' : from}.xhtml"
                   value="#{empty from ? 'Ver' : 'Selecionar'}"
             propagation="#{empty from ? 'none' : 'default'}"
                      id="subGrupoViewId">
                <f:param name="subGrupoId"
                        value="#{_subGrupo.id}"/>
            </s:link>
            #{' '}
            <s:link view="/resources/SubGrupoEdit.xhtml"
                   value="Editar"
             propagation="none"
                      id="subGrupoEdit"
                rendered="#{empty from}">
                <f:param name="subGrupoId"
                        value="#{_subGrupo.id}"/>
            </s:link>
        </rich:column>
    </rich:dataTable>

    </div>
    </rich:panel>

    <div class="tableControl">

        <s:link view="/resources/SubGrupoList.xhtml"
            rendered="#{subGrupoList.previousExists}"
               value="#{messages.left}#{messages.left} #{messages.firstPage}"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>

        <s:link view="/resources/SubGrupoList.xhtml"
            rendered="#{subGrupoList.previousExists}"
               value="#{messages.left} #{messages.previousPage}"
                  id="previousPage">
            <f:param name="firstResult"
                    value="#{subGrupoList.previousFirstResult}"/>
        </s:link>

        <s:link view="/resources/SubGrupoList.xhtml"
            rendered="#{subGrupoList.nextExists}"
               value="#{messages.nextPage} #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult"
                    value="#{subGrupoList.nextFirstResult}"/>
        </s:link>

        <s:link view="/resources/SubGrupoList.xhtml"
            rendered="#{subGrupoList.nextExists}"
               value="#{messages.lastPage} #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult"
                    value="#{subGrupoList.lastFirstResult}"/>
        </s:link>

    </div>

</ui:define>

</ui:composition>
